package hiatao.puzzle.fragment;

import haitao.puzzle.R;
import hiatao.puzzle.adapter.MyFragmentPagerAdapter;
import hiatao.puzzle.widget.PagerSlidingTabStrip;
import java.util.ArrayList;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

public class RankFragment extends Fragment{

	
	private View rootView;
	private PagerSlidingTabStrip tabs;
	private ViewPager pager;
	RankAllFragment allFragment;
	RankFriendsFragment friendsFragment;
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		rootView = inflater.inflate(R.layout.fragment_rank, container, false);
		findView();
		init();
		return rootView;
	}

	private void init() {
		ArrayList<Fragment> fragments = new ArrayList<Fragment>();
		allFragment = new RankAllFragment();
		friendsFragment = new RankFriendsFragment();
		fragments.add(allFragment);
		fragments.add(friendsFragment);
		final String[] titles = {"所有玩家","我的好友"};
		pager.setAdapter(new MyFragmentPagerAdapter(getChildFragmentManager(), fragments, titles));
		tabs.setViewPager(pager);
		tabs.setShouldExpand(true);
	}

	private void findView() {
		pager = (ViewPager) rootView.findViewById(R.id.pager);
		tabs = (PagerSlidingTabStrip) rootView.findViewById(R.id.tabs);
	}
	
}
